/*
** main.c -- contains main function
** Veronika Dikoun
** Billy Lin
** CPSC 317 2012W2
*/

#include "rtspd.h"
#include <stdio.h>
#include <stdlib.h>

char* get_port(char* port)
{
	int port_num = atoi(port);

	if ((port_num < 1025) || (port_num > 65535))
	{
		fprintf(stderr,"Invalid port number. Valid range: [1025, 65535]\n");
		exit(1);
	}
	
	return port;
}

int main(int argc, char *argv[])
{

	if (argc != 2)
	{
		fprintf(stderr,"usage: rtspd [port number]\n");
		exit(1);
	}

	printf("Welcome to RTSPd!\n");

	char* port = get_port(argv[1]);
	int serve_condition = serve(port);
	
	return serve_condition;
}
